package controller

import (
	"context"
	v1 "wh-1-backend/api/v1"
	"wh-1-backend/internal/service"
)

type cFunction struct {
}

var Function = cFunction{}

func (f *cFunction) ListByPid(ctx context.Context, req *v1.FunctionListByPidReq) (res *v1.FunctionListRes, err error) {
	list, err := service.Function().ListByPid(ctx, req.Pid)
	if err != nil {
		return
	}
	res = &v1.FunctionListRes{
		List: list,
	}
	return
}

func (f *cFunction) List(ctx context.Context, req *v1.FunctionListReq) (res *v1.FunctionListRes, err error) {
	list, err := service.Function().List(ctx)
	res = &v1.FunctionListRes{
		List: list,
	}
	return
}
